package com.fanshuai2.niuke.strings;

import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Scanner;

public class Password2 {
    static String enc(String keyword, String text) {
        keyword = keyword.toUpperCase();

        char[] keyArr = keyword.toCharArray();
        char[] textArr = text.toCharArray();

        List<Character> list = new ArrayList<>();
        for (int i = 0; i < keyArr.length; i++) {
            if (!list.contains(keyArr[i])) {
                list.add(keyArr[i]);
            }
        }
        for (int i = 0; i < 26; i++) {
            char ch = (char) ('A' + i);
            if (!list.contains(ch)) {
                list.add(ch);
            }
        }


        StringBuilder b = new StringBuilder();
        for (int i = 0; i < textArr.length; i++) {
            char ch = textArr[i];
            if (ch == ' ') {
                b.append(ch);
            } else if (ch < 'a') {
                int n = ch - 'A';
                b.append(list.get(n));
            } else {
                int n = ch - 'a';
                char c = (char)(list.get(n) + ('a' - 'A'));
                b.append(c);
            }
        }

        return b.toString();
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        while (in.hasNextLine()) {
            String keyword = in.nextLine();
            String input = in.nextLine();
            System.out.println(enc(keyword, input));
        }
    }
}
